package com.eportal.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.eportal.base.BaseDAO;
import com.eportal.domain.DistributeLog;
import com.eportal.service.DistributeLogService;
import com.framework.jqgrid.JqGridPager;

@Service("distributeLogService")
public class DistributeLogServiceImpl  implements DistributeLogService{
	
	@Resource(name="dao")
	private BaseDAO dao;

	@Override
	public DistributeLog get(Long sid){
		DistributeLog distributeLog = (DistributeLog)dao.getById(DistributeLog.class, sid);
		return distributeLog;
	}
	
	@Override
	public List<Map<String, Object>> list(JqGridPager jqGridPager) {
		 String sql = "select ab.* from("
		 		+ "select t.sid,t.opentype,t.otime as otime1,t.agtcode,t.communityid,"
		 		+ "TO_CHAR (t.otime,'yyyy-MM-dd HH24:mi:ss') as otime,a.agtname,c.communityname,"
		 		+ "c.citycode,u.tel,u.auname,l.install_lock_name as installName "
		 		+ "from TOPENLOG t "
		 		+ "left join t02_agtent a on t.agtcode=a.agtcode "
		 		+ "left join t03_community c on t.communityid=c.sid "
		 		+ "left join t04_users u on t.auid=u.userid "
		 		+ "left join t05_locks l on t.pid=l.pid"
		 		+ ") ab";
	     return dao.query(sql, jqGridPager);
	}

	@Override
	public DistributeLog save(DistributeLog distributeLog) throws Exception {
		dao.save(distributeLog);
        return distributeLog;
	}
	
	
	
}
